package cn.yunhe.biz;
import cn.yunhe.pojo.Page;
import org.apache.ibatis.session.SqlSession;
import cn.yunhe.dao.NewsMapper;
import cn.yunhe.pojo.News;
import cn.yunhe.util.SqlSessionFactoryUtil;
import java.util.List;


public class NewsService {
    SqlSession session = SqlSessionFactoryUtil.getSession();
    NewsMapper newsMapper=session.getMapper(NewsMapper.class);

    public int addNews(News news){
        int flag = newsMapper.addNews(news);
        session.commit();
        return flag;
    }

    public List<News> getNewsByPage(Page page){
        return newsMapper.getNewsByPage(page);
    }

    public int getNewsCount(String title){
        return newsMapper.getNewsCount(title);
    }

    public News getNewsByNewsId(int newsId){
        return newsMapper.getNewsByNewsId(newsId);
    }

    public int updateNewsByNews(News news){
        int flag= newsMapper.updateNewsByNews(news);
        session.commit();
        return flag;
    }
    public List<News> helpSerchNews(String newstitle){
        return  newsMapper.helpSerchNews(newstitle);
    }

}
